// pages/components/ArticleList/ArticleList.js

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item:{
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
   
  },

  /**
   * 组件的方法列表
   */
  methods: {
    cannel(){
         console.log(123)
         this.triggerEvent('cannel')
    },
    //更新用户信息
    getPhoneNumber (e) {
       console.log(e.detail.errMsg)
       console.log(e.detail.iv)
       console.log(e.detail.encryptedData)
      var userInfo= wx.getStorageSync('userInfo');
       var _self=this;

        wx.login({
           success (res) {
            if (res.code) {
                     wx.request({
                      url:getApp().globalData.baseUrl+'/wx/user/getUserPhone',
                      method:"post",
                      data:{
                        code:res.code,
                        encryptedData:e.detail.encryptedData,
                        iv:e.detail.iv,
                        openid:userInfo.openid
                      },
                      header:{
                         'openid':userInfo.openid, //公用请求头
                         'content-type': 'application/json'
                      },
                      success: function(res) { 
                      userInfo.phone=res.data.obj;
                      wx.setStorageSync('userInfo',userInfo);
                      console.log(res.data.obj)  
                      _self.triggerEvent('loginSuccess')
                   }
                 })  
            }
          }
        })

    }
  }
})
